home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1995 January
/
1995-01b.d64
/
life inst
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
7KB
|
186 lines
10 print"[147][152]";:poke53281,15:poke53280,15
20 fori=1to23:reada$:ifa$="[157]"thengosub80:goto200
50 printa$:next:gosub80:goto20
80 p=p+1:print" [154] [208]ress <[211][208][193][195][197]> to continue [208]age"p"[157] [145][152]"
90 getb$:ifb$=""then90
100 print"[147]";:return
200 print"[147] [208]ress <[209]> to [209][213][201][212]
210 [153]"cont (NULL)ress <(NULL)> to (NULL)val(NULL)right$val(NULL)
220 print"[152] [208]ress <[204]> to load [204][201][198][197]
240 [161]k$:[139]k$[179][177]"r"[175]k$[179][177]"l"[175]k$[179][177]"q"[167]240
250 [139]k$[178]"r"[167][138]
260 [139]k$[178]"q"[167][153]"def valnjoy the programs and hug someone!print#":[128]
300 f$[178]"life":[153]"loadlistloadf$,8print#":[151]198,2:[151]631,19:[151]632,131:[128]
10000 [131]"
10010 data"[154] [212]he [199]ame of [204]ife",
10030 data" [211]imulations of [194]irth and [196]eath
10040 [131]" right$n a lenlosed lenomputer (NULL)niverse",
10060 [131]"print#(NULL)right$ascval is a fascinating game devised by
10070 data"mathametican [202]ohn [200]. [195]onway, and
10080 [131]"introduced in the '(NULL)athematical chr$ames'
10090 data"column of [211]cientific [193]merican in 1970.
10100 [131]"right$t is not a game at all in the usual
10110 data"sense.",
10130 data"[204]ife can be visualized as a simulation
10140 [131]"of the history of a colony of organisms
10150 data"which occupy the squares of a grid like
10160 [131]"checkers on a checker board.
10170 data"
10180 [131]"valach square can be occupied by one
10190 data"organism, or cell. [211]ince each square is
10200 [131]"surrounded by eight neighboring
10210 data"squares, each cell can have up to eight
10220 [131]"neighbors. (NULL)ules for the survival of
10230 data"cells make the colony of cells
10240 [131]"unpredictable.",
10260 [131]"(NULL)urvival of cells can be expressed in
10270 data"the following two rules:
10280 [131]" 1. (NULL)urvival: valach cell with either
10290 data"two or three neighbors survives to the
10300 [131]"next generation.
10310 data" 2. [194]irth: [193] cell is born in each
10320 [131]"empty area with exactly three
10330 data"neighbors.",
10350 data"[194]irths and deaths take place
10360 [131]"simultaneously so that the population
10370 data"of one generation will determine the
10380 [131]"population of the next generation.",
10400 [131]"(NULL)he obvious implication of the rule of
10410 data"survival is that cells which have more
10420 [131]"than three neighbors will die.
10430 data"[212]herefore, either overpopulation or
10440 [131]"isolation is fatal to cells.",
10460 [131]"(NULL)he rule of birth dictates that the
10470 data"population density must be ideal for
10480 [131]"birth to occur.",
10500 [131]"peeky applying these simple rules and an
10510 data"initial colony of a few cells,
10520 [131]"extraordinary and elaborate colonies
10530 data"will emerge.",
10550 data"[195]olonies can grow to immense
10560 [131]"proportions only to recede and die out
10570 data"entirely. [211]ome colonies reach a steady
10580 [131]"state in which no cells die and no new
10590 data"cells are born. [207]ther colonies devolop
10600 [131]"into patterns which repeat over a
10610 data"period of two or more generations.
10620 [131]"(NULL)hese oscillating patterns can be
10630 data"objects of beautifully animated
10640 [131]"symmetry and sometimes produce
10650 data"surprising results.",,,
10670 data"[154][200][207][215] [212][207] [208][204][193][217] [192]",
10690 data"[152][215]hen the program is run, the word
10700 [131]"'(NULL)right$ascval' is displayed on the screen. (NULL)his
10710 data"word then becomes a life colony, which
10720 [131]"you can watch for 232 generations. (NULL)he
10730 data"sequence then repeats. [217]ou can press
10740 [131]"the '(NULL)' key at any time to see the
10750 data"instructions.",
10770 data"[212]here are two basic modes of operation
10780 [131]"in the program. (NULL)ne is the str$(NULL)atn(NULL) mode
10790 data"which allows you to put an initial
10800 [131]"colony on the screen. (NULL)he other is the
10810 data"[210][213][206] mode in which the computer
10820 [131]"calculates and displays successive
10830 data"generations of cells.",
10850 data"[217]ou can use the [195][213][210][211][207][210] keys or [202][207][217][211][212][201][195][203]
10860 [131]"(port 2) to draw on the screen in the
10870 data"[196][210][193][215] mode. [212]he [210][197][212][213][210][206] key or fire
10880 [131]"button turns the drawing on and off.
10890 data"[217]ou can press [204] to turn the lines on
10900 [131]"and off. (NULL)he function keys control
10910 data"other drawing options. [208]ress [198]1 to
10920 [131]"clear the screen, asc3 to change the
10930 data"color of the grid and [198]5 to see the
10940 [131]"instructions. (NULL)ress asc7 to go to the (NULL)(NULL)(NULL)
10950 data"mode. [212]he function keys perform
10960 [131]"different operations in the (NULL)(NULL)(NULL) mode.
10970 data"[212]hey are displayed at the bottom of the
10980 [131]"screen. (NULL)ress asc7 to (NULL)(NULL)(NULL)(NULL) and (NULL)(NULL)(NULL). (NULL)he
10990 data"colony is not erased when you press [198]1
11000 [131]"and return to the str$(NULL)atn(NULL) mode. (NULL)his
11010 data"allows you to modify the colony on the
11020 [131]"screen. (NULL)ressing (NULL) when in str$(NULL)atn(NULL) will
11030 data"[209][213][201][212] the game.",
11050 data"[154][195][207][205][205][207][206] [204][201][198][197] [198][207][210][205][211] [192]",
11070 data"[152][212]he second screen of instructions
11080 [131]"displays some common (NULL)right$ascval forms. (NULL)hey
11090 data"illustrate some of the interesting
11100 [131]"results of applying lenonway's simple
11110 data"rules.",
11130 data"[198]or example, consider the [194][207][216]. ** [212]he
11140 [131]"four cells are situated in ** such
11150 data"a way that each cell has 3 neighbors.
11160 [131]"(NULL)ince each cell has 3 neighbors, it
11170 data"survives to the next generation. [212]he
11180 [131]"empty squares surrounding the box have
11190 data"only 2 neighbors each. [211]ince 3
11200 [131]"neighbors are required for birth, no
11210 data"new cells are born adjacent to the box.
11220 [131]"(NULL)herefore the box ramains stable from
11230 data"one generation to the next. [207]ne might
11240 [131]"say that such colonies are immortal.",
11260 [131]"(NULL)here are many other stable forms. (NULL)ome
11270 data"can be quite large. [198]or example the
11280 [131]"peek(NULL)atn(NULL) * can be any length.left$owever larger
11290 data" * * stable forms seldom occur
11300 [131]" ** naturally.
11310 data"[208]erhaps more interesting than stable
11320 [131]"forms are (NULL)(NULL)lenright$(NULL)(NULL)atn(NULL)(NULL)(NULL)(NULL), or patterns that
11330 data"repeat over a period of 2 or more
11332 [131]"generations.",,
11340 [131]" valxample tan ** *
11350 data" *** ** **
11360 [131]" **** *** ** **
11370 data" ** *
11380 [131]" peeklinker (NULL)oad peekeacon lenlock",
11400 [131]"(NULL)he smallest and most common oscillator
11410 data"is the [194][204][201][206][203][197][210], consisting of 3 cells
11420 [131]"in a row. (NULL)he cells at each end have
11430 data"only one neighbor, so they both die.
11440 [131]"(NULL)he cell in the middle has 2 neighbors,
11450 data"so it survives. [205]eanwhile, the squares
11460 [131]"on each side of the middle cell have 3
11470 data"neighbors, so new cells are born there.
11480 [131]"(NULL)he result is that a row of 3 cells
11490 data"appears at right angles to the old row
11500 [131]"in the next generation. (NULL)he following
11510 data"generation will 'blink' back to the
11520 [131]"original configuration, so the
11530 data"oscillator has a period of 2
11540 [131]"generations. (NULL)he other oscillators
11550 data"displayed are also 2 period
11560 [131]"oscillators",
11580 [131]"(NULL)he first colony at the bottom of the
11590 data"screen develops into a period 3
11600 [131]